package com.north.light.androidutils.permission;

import android.content.Context;
import android.content.DialogInterface;

import com.north.light.androidutils.R;
import com.north.light.libpermission.intercept.PermissionIntercept;
import com.north.light.libpermission.intercept.dialog.InterceptDialogCallback;

/**
 * FileName: PermissionIntercept1
 * Author: lzt
 * Date: 2022/8/24 09:56
 */
public class PermissionIntercept1 implements PermissionIntercept {
    @Override
    public boolean ensureDialog(Context context, InterceptDialogCallback interceptDialog) throws Exception {
        PermissionDialog.Builder builder = new PermissionDialog.Builder(context);
        builder.setIcon(R.mipmap.ic_launcher)  //设置图标
                .setTitle("我是对话框")      //设置标题
                .setMessage("请求权限")     //设置消息
                .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        interceptDialog.confirm();
                    }
                })
                .setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        interceptDialog.cancel();
                    }
                })
                .create()   //创建
                .show();    //显示
        return true;
    }
}
